@model Orchard.Queries.Sql.ViewModels.SqlQueryViewModel

<script asp-src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.25.2/codemirror.js" depends-on="admin" at="Foot"></script>
<script asp-src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.25.2/mode/javascript/javascript.js" at="Foot"></script>
<script asp-src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.25.2/mode/sql/sql.js" at="Foot"></script>

<fieldset class="form-check">
    <label class="form-check-label">
        <input asp-for="ReturnDocuments" type="checkbox" class="form-check-input" checked="@Model.ReturnDocuments" /> @T["Return Documents"]
        <span class="hint">@T["Check to return the corresponding documents."]</span>
    </label>
    <span class="hint">@T["When checked, the result has to be a list of document ids."]</span>
</fieldset>

<fieldset class="form-group">
    <label asp-for="Query">@T["Query"]</label>
    <textarea asp-for="Query" rows="12" class="form-control"></textarea>
    <span class="hint">@T["The SQL query to execute."]</span>
</fieldset>

<script at="Foot">
    $(function () {
        CodeMirror.fromTextArea(document.getElementById('@Html.IdFor(x => x.Query)'), { mode: "text/x-sql", lineNumbers: true, viewportMargin: Infinity });
    });
</script>
